<template>
  <transition name="fade">
    <div class="dialog-main" v-show="showDialog">
      <div class="dialog">
        <div class="info-tro">
          <div class="info-title">
            <i v-if="rst.is_premium">品牌</i>
            <span>{{rst.name}}</span>
          </div>
          <div class="info-list">
            <ul>
              <li>
                <h3>{{rst.rating}}</h3>
                <span>评分</span>
              </li>
              <li>
                <h3>{{rst.recent_order_num}}单</h3>
                <span>月票</span>
              </li>
              <li v-if="rst.delivery_mode">
                <h3>蜂鸟专送</h3>
                <span>约{{rst.order_lead_time}}分钟</span>
              </li>
              <li>
                <h3>￥{{rst.float_delivery_fee}}</h3>
                <span>配送费</span>
              </li>
              <li>
                <h3>{{(rst.distance/1000).toFixed(1)}}Km</h3>
                <span>距离</span>
              </li>
            </ul>
            <!-- 公告 -->
            <div class="announcement">公告</div>
            <div class="announc-info">{{rst.promotion_info}}</div>
          </div>
        </div>
      </div>
      <!-- 叉号 -->
      <div class="cancel-dialog" @click="$emit('changeShowDialog')">
        <img src="https://fuss10.elemecdn.com/8/ba/bcfa8cc62b20e044bd2ea1c1c7f3dpng.png?imageMogr/format/webp/" alt>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: 'MyDialog',
  props: {
    rst: Object,
    showDialog: Boolean
  }
}
</script>

<style lang="less" scoped>
.dialog-main {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  .dialog {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 10px;
    background-color: #fff;
    width: 250px;
    padding: 20px 30px;
    .info-tro {
      .info-title {
        text-align: center;
        i {
          background-color: yellow;
          font-style: inherit;
          margin-right: 5px;
          color: #666;
        }
        span {
          font-size: 18px;
          font-weight: 700;
        }
      }
      .info-list {
        padding-top: 20px;
        ul {
          display: flex;
          justify-content: space-around;
          li {
            flex: 1;
            white-space: nowrap;
            margin: 0 5px;
            text-align: center;
            background-color: #eee;
            padding: 5px;
            h3 {
              font-weight: 800;
              font-size: 12px;
            }
            span {
              display: inline-block;
              margin-top: 5px;
              font-size: 12px;
            }
          }
        }
        .announcement {
          position: relative;
          margin-top: 20px;
          text-align: center;
          &:before,
          &:after {
            content: '——';
            top: 0;
            position: absolute;
            color: #666;
          }
          &:before {
            left: 53px;
          }
          &:after {
            right: 53px;
          }
        }
        .announc-info {
          margin-top: 10px;
          font-size: 12px;
        }
      }
    }
  }
  .cancel-dialog {
    position: absolute;
    top: 437px;
    left: 166px;
    width: 40px;
    img {
      width: 100%;
    }
  }
}
.fade-enter-active,
.fade-leave-active {
  transition: all 0.5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
</style>
